﻿using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Xml;

namespace CodeGecko.SocialControl {
    public class Settings {

        /// <summary>
        /// ShareThis static class.
        /// </summary>
        public class ShareThis : ComplexProperty<string> {
            public ShareThis() : base() {
                AddProperty<string>("publisher", new SimpleProperty<string>(String.Empty));
                AddProperty<string>("tracking", new SimpleProperty<string>(String.Empty));
                AddProperty<string>("send_services", new SimpleProperty<string>(String.Empty));

            }
            /// <summary>
            /// Your ShareThis publisher ID.
            /// </summary>
            public static int Publisher { get; set; }

            /// <summary>
            /// Boolean to specify whether to enable ShareThis analytics tracking.
            /// </summary>
            public bool Tracking { get; set; }

            /// <summary>
            /// 
            /// </summary>
            public static string SendServices { get; set; }

            /// <summary>
            /// 
            /// </summary>
            public static string ExcludeServices { get; set; }

            /// <summary>
            /// Header title for the ShareThis popup box.
            /// </summary>
            public static string HeaderTitle { get; set; }
        }

        public class AddThis
        {

        }
    }

    public class Config : ConfigurationSection {
        [ConfigurationProperty("settings")]
        public ServiceSettingsCollection Settings {
            get { return (ServiceSettingsCollection)this["services"]; }
            set { this["services"] = value; }
        }
    }

    public class ServiceSettingsCollection : ConfigurationElementCollection {
        #region .ctor
        public ServiceSettingsCollection() { }
        #endregion
        
        #region Properties
        public override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.AddRemoveClearMap; } }
        protected override ConfigurationElement CreateNewElement() { return new ServiceElement(); }
        protected override ConfigurationElement CreateNewElement(string elementName) { return new ServiceElement(elementName); }
        protected override object GetElementKey(ConfigurationElement element) { return ((ServiceElement)element).Name; }

        public new string AddElementName { get { return base.AddElementName; } set { base.AddElementName = value; } }
        public new string ClearElementName { get { return base.ClearElementName; } set { base.ClearElementName = value; } }
        public new string RemoveElementName { get { return base.RemoveElementName; } set { base.RemoveElementName = value; } }
        #endregion
    }

    public class ServiceElement : ConfigurationElement {
        #region Properties
        [ConfigurationProperty("name", IsKey=true, IsRequired=true)]
        public string Name { get { return (string)this["name"]; } set { this["name"] = value; } }
        #endregion

        #region .ctor
        public ServiceElement() : base() { }
        public ServiceElement(string elementName) { Name = elementName; }
        #endregion
    }
}